package com.stox.ui.swing.widget;

import java.beans.PropertyVetoException;

import org.springframework.stereotype.Component;

import com.stox.ui.swing.util.ThrowableReporter;
import com.stox.ui.swing.view.InternalFrameView;
import com.stox.ui.swing.widget.wrapper.JDesktopPane;

@Component
public class MainDesktop extends JDesktopPane {
	private static final long serialVersionUID = 5436616201523947340L;

	public static final int MAXIMIZED_LAYER = 1;
	public static final int ICONIFIED_LAYER = 2;
	
	public void addView(InternalFrameView view){
		view.setVisible(true);
		moveToBack(view);
		add(view,MAXIMIZED_LAYER);
		try {
			view.setSelected(true);
		} catch (PropertyVetoException e) {
			ThrowableReporter.report(e);
		}
	}
	
	public void moveToFront(InternalFrameView view){
		setLayer(view, ICONIFIED_LAYER);
	}
	
	public void moveToBack(InternalFrameView view){
		setLayer(view, MAXIMIZED_LAYER);
	}
	
}
